package icu.groot.alan.hotel.entity.req;

import icu.groot.alan.hotel.util.BizException;
import icu.groot.alan.hotel.util.ResultCodeEnum;

public class AccountUpdatePasswordRo {

    /**
     * 用户原始密码
     */
    private String accPassword;

    /**
     * 用户新密码
     */
    private String accNewPassword;

    /**
     * 用户新密码二次填入
     */
    private String accAgainNewPassword;

    public String getAccPassword() {
        return accPassword;
    }

    public void setAccPassword(String accPassword) {
        this.accPassword = accPassword;
    }

    public String getAccNewPassword() {
        return accNewPassword;
    }

    public void setAccNewPassword(String accNewPassword) {
        this.accNewPassword = accNewPassword;
    }

    public String getAccAgainNewPassword() {
        if (accNewPassword == null || accNewPassword.trim().equals("") || accAgainNewPassword == null || accAgainNewPassword.trim().equals("")){
            throw new BizException(ResultCodeEnum.FAILED.setMessage("密码不能为空"));
        }
        if (!accAgainNewPassword.equals(accNewPassword)){
            throw new BizException(ResultCodeEnum.FAILED.setMessage("两次密码不同"));
        }
        if (accAgainNewPassword.equals(accPassword)){
            throw new BizException(ResultCodeEnum.FAILED.setMessage("新密码不能和旧密码相同"));
        }
        return accAgainNewPassword;
    }

    public void setAccAgainNewPassword(String accAgainNewPassword) {
        this.isStringNull(accNewPassword, "新密码不能为空");
        this.accAgainNewPassword = accAgainNewPassword;
    }
    private void isStringNull(String val, String remind){
        if (val == null || val.equals("")){
            throw new BizException(ResultCodeEnum.FAILED.setMessage(remind));
        }
    }
}
